package com.wlf.mq.customer;

import com.rabbitmq.client.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;

/**
 * @author lingfeng.wei
 * @date 2021/11/4 17:00
 */
public class UtApiListener  implements ChannelAwareMessageListener {

    private static final Logger LOG = LoggerFactory.getLogger(UtApiListener.class);

    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        LOG.info("---API订单队列开始消费---->{}", message.getMessageProperties().getConsumerQueue());
        // 1.解析message
        String msg = new String(message.getBody(),"UTF-8");
        LOG.info("开始消费，接收到信息:{}",msg);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        return;
    }
}
